{% extends "main/base.html" %}
{% load static i18n %}
{% block title %}{% trans '添加设备组装' %}{% endblock %}
{% block content %}
<section class="col-lg-offset-3 col-lg-7">
    <section class="panel">
        <header class="panel-heading">
            {% trans "添加设备组装" %}
            {% if form.errors %}
            <p>{% trans "您提交的数据有误,请认真检查!" %}</p>
            {% endif %}
            {{ form.non_field_errors }}
        </header>
        <div class="panel-body">
            <form method="post" class="form-horizontal" enctype="multipart/form-data" action="{% url 'main:equipment_als_create' %}?next={{ request.GET.next }}&e_pk={{ request.GET.e_pk }}">{% csrf_token %}
                {% if request.user.is_authenticated %}
                    <input type="hidden" name="created_by" id="id_created_by" value="{{ request.user.id }}">
                {% endif %}
                <div class="form-group">
                    <div class="col-lg-2">{{ form.assembly_name.label_tag }}</div>
                    <div class="col-lg-10">{{ form.assembly_name }}{{ form.assembly_name.errors }}</div>
                </div>
                {% if request.GET.e_pk %}
                <input type="hidden" name="equipment" value="{{ request.GET.e_pk }}">
                {% else %}
                <div class="form-group">
                    <div class="col-lg-2">{{ form.equipment.label_tag }}</div>
                    <div class="col-lg-10">
                        <div class="input-group">
                            <input class="form-control" type="text" id="equipment_search" value="" placeholder="搜索设备" onchange="refreshBtn();">
                            <span class="input-group-btn"><label class="btn btn-primary" id="search_btn" onclick="loadXMLDoc();">搜索</label></span>
                        </div>
                    </div>
                    <div class="col-lg-offset-2 col-lg-10">
                        <select name="equipment" class="selectpicker form-control" data-live-search="true" required id="id_equipment">
                            <option value="" selected>---------</option>
                        </select>
                    </div>
                </div>{% endif %}
                <div class="form-group">
                    <div class="col-lg-2">{{ form.is_confirmed.label_tag }}</div>
                    <div class="col-lg-4">
                        <div class="switch switch-square"
                            data-on-label="<i class=' fa fa-check'></i>"
                            data-off-label="<i class='fa fa-times'></i>">
                            {{ form.is_confirmed }}
                        </div>{{ form.is_confirmed.errors }}
                    </div>
                    <div class="col-lg-2">{{ form.is_active.label_tag }}</div>
                    <div class="col-lg-4">
                        <div class="switch switch-square"
                            data-on-label="<i class=' fa fa-check'></i>"
                            data-off-label="<i class='fa fa-times'></i>">
                            {{ form.is_active }}
                        </div>{{ form.is_active.errors }}
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-2">{{ form.notes.label_tag }}</div>
                    <div class="col-lg-10">{{ form.notes }}{{ form.notes.errors }}</div>
                </div>
                <div class="form-group" align="right">
                    <div class="col-lg-12">
                        <button type="submit" class="btn btn-primary">{% trans "提交" %}</button>
                    </div>
                </div>
            </form>
        </div>
    </section>
</section>
{% endblock %}
{% block this_js %}
<script type="text/javascript" src="{% static 'main/js/load_equipment.js' %}"></script>
<script type="text/javascript" src="{% static 'flatlab/js/bootstrap-switch.js' %}"></script>
{% endblock %}